<?php
	require_once '../utils/conn.php';
	include_once '../models/updateLog.php';
	
	date_default_timezone_set("PRC");
	
	function setUpdatetime($time, $type, $content) {
		$timestamp = strtotime($time);
		if ($timestamp != null) {
			$query = "UPDATE t_update_time SET timestamp='$timestamp', content='$content' WHERE type=$type";
			$result = mysql_query($query) or die("update failed：". mysql_error());
			echo "更新日志成功！";
		}
		else
		{
			echo "时间格式错误！<br>例如:".date("Y-m-d H:i:s",time());
		}
	}
	
	function getUpdatetime($type){
		$query = "SELECT *from t_update_time WHERE type=$type";
		$result = mysql_query($query) or die("update failed：". mysql_error());
		$row = mysql_fetch_array($result, MYSQL_ASSOC);
		$updateLog = new UpdateLog();
		$updateLog->setContent($row['content']);
		$updateLog->setUpdateTime($row['timestamp']);
		return $updateLog;
	}
?>